package com.bonuo.crm.service.impl;

import com.bonuo.crm.domain.Contact;
import com.bonuo.crm.mapper.ActivityMapper;
import com.bonuo.crm.mapper.ContactMapper;
import com.bonuo.crm.service.ContactService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLIntegrityConstraintViolationException;
import java.util.List;

@Service
public class ContactServiceImpl implements ContactService {
    @Autowired
    private ContactMapper contactMapper;
    @Override
    public List<Contact> selectContactList(Contact contact) {
        return contactMapper.selectContactList(contact);
    }

    @Override
    public AjaxResult insertContact(Contact contact) {
//        try {
//        Contact repeat = contactMapper.selectPhoneRepeat(contact.getPhone());
//        if(repeat != null){
//            return AjaxResult.error("手机号已存在，请重新输入");
//        }
        Integer integer = contactMapper.insertContact(contact);
        return AjaxResult.success(integer);

    }

    @Override
    public Integer deleteContactById(Integer id) {
        return contactMapper.deleteContactById(id);
    }

    @Override
    public AjaxResult updateContact(Contact contact) {
        Integer integer = contactMapper.updateContact(contact);
        return AjaxResult.success(integer);
    }

    @Override
    public Integer selectContactByFacultyOrAgentId(Integer id,Integer type) {
        return contactMapper.selectContactByFacultyOrAgentId(id,type);
    }

}
